package com.zjuee.web.warning.service.impl.handledata;

import com.zjuee.base.utils.DateUtils;
import com.zjuee.core.translation.handledata.impl.AbstractDataHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import com.zjuee.vo.AlarmPromptVo;

import java.util.Map;

@Slf4j
@Component(value = "alarmPromptHandle")
public class AlarmPromptHandle extends AbstractDataHandler {

    @Override
    public <T> T getData(T data, Map<Object, Object> map, String... str) {
        AlarmPromptVo alarmPromptVo = (AlarmPromptVo) data;
        AlarmPromptVo result = new AlarmPromptVo();
        BeanUtils.copyProperties(data, result);
        result.setWapLevel(map.get(alarmPromptVo.getWapLevel() + "" + str[0]) == null ? "" : map.get(alarmPromptVo.getWapLevel() + "" + str[0]).toString());
        result.setWapStatusCN(map.get(alarmPromptVo.getWapStatus() + "" + str[1]) == null ? "" : map.get(alarmPromptVo.getWapStatus() + "" + str[1]).toString());
        result.setWapName(map.get(alarmPromptVo.getWapName() + "" + str[2]) == null ? "" : map.get(alarmPromptVo.getWapName() + "" + str[2]).toString());
        result.setWapType(map.get(alarmPromptVo.getWapType() + "" + str[3]) == null ? "" : map.get(alarmPromptVo.getWapType() + "" + str[3]).toString());
        result.setBciProvince(map.get(alarmPromptVo.getBciProvince() + "" + str[4]) == null ? "" : map.get(alarmPromptVo.getBciProvince() + "" + str[4]).toString());
        result.setBciCity(map.get(alarmPromptVo.getBciCity() + "" + str[5]) == null ? "" : map.get(alarmPromptVo.getBciCity() + "" + str[5]).toString());
        result.setBciArea(map.get(alarmPromptVo.getBciArea() + "" + str[6]) == null ? "" : map.get(alarmPromptVo.getBciArea() + "" + str[6]).toString());
        result.setBciStreet(map.get(alarmPromptVo.getBciStreet() + "" + str[7]) == null ? "" : map.get(alarmPromptVo.getBciStreet() + "" + str[7]).toString());
        result.setWapTimeStr(DateUtils.parsemmss(result.getWapTime()));
        result.setWapModifiedTimeStr(DateUtils.parsemmss(result.getWapModifiedTime()));
        if (result.getBciProvince() != null) result.setEPA(result.getBciProvince() + "环保局");
        if (result.getBciCity() != null) result.setEPA(result.getBciCity() + "环保局");
        if (result.getBciArea() != null) result.setEPA(result.getBciArea() + "环保局");
        return (T) result;
    }
}
